//
//  ViewController.m
//  07-UIViewController生命周期
//
//  Created by mafeng on 16/7/22.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ViewController.h"
#import "FirstViewController.h"

@interface ViewController ()

@end

@implementation ViewController
// push 一个新的视图控制器
// loadView viewdidload viewwilldisapper
// 以上三个方法会插在一个视图控制器的viewwilldisapear 和 viewdiddisapear
- (void)loadView {
    [super loadView];
    NSLog(@"%@ --- %s", [self class], __FUNCTION__);
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(buttonClick:)];
     NSLog(@"%@ --- %s", [self class], __FUNCTION__);
}
// 视图将要出现时, 就会调用
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"%@ --- %s", [self class], __FUNCTION__);
}
// 视图已经出现时, 就会调用
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"%@ --- %s", [self class], __FUNCTION__);
}
// 视图将要消失, 只要有一点消失, 就会调用
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"%@ --- %s", [self class], __FUNCTION__);
}
// 视图已经完全消失, 就会调用
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"%@ --- %s", [self class], __FUNCTION__);
}
#pragma mark -- buttonClick
- (void)buttonClick:(UIBarButtonItem *)button {
    FirstViewController *first = [[FirstViewController alloc] init];
    [self.navigationController pushViewController:first animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
